import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:flutter_hx/router/app_pages.dart';
import 'package:get/get.dart';
import 'root_logic.dart';

class RootView extends GetView<RootLogic> {
  const RootView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
     return GetBuilder<RootLogic>(
       builder: (logic){
         return SafeArea(
           top: false,
           child: Scaffold(
             body: IndexedStack(
                 index: logic.currentIndex,
                 children: logic.mainIndexStackPages
             ),
             bottomNavigationBar: BottomNavigationBar(
               currentIndex: logic.currentIndex,
               showSelectedLabels: true,
               type: BottomNavigationBarType.fixed,
               showUnselectedLabels: true,
               onTap: (index)=>logic.currentIndex=index,
               unselectedFontSize: 10.0,
               selectedFontSize: 10.0,
               backgroundColor: Colors.white,
               selectedItemColor:const Color.fromRGBO(51, 51, 51, 1),
               unselectedItemColor: const Color.fromRGBO(150, 151, 153, 1),
               elevation: 0,
               items: [
                 BottomNavigationBarItem(
                     icon:logic.currentIndex!=0?
                     Image.asset("assets/images/icon_tab_home.png",gaplessPlayback: true)
                         :Image.asset("assets/images/icon_tab_home_select.png",gaplessPlayback: true),
                     label: "首页"
                 ),
                 BottomNavigationBarItem(
                   icon:logic.currentIndex!=1?
                   Image.asset("assets/images/icon_tab_pm.png",gaplessPlayback: true)
                       :Image.asset("assets/images/icon_tab_pm_select.png",gaplessPlayback: true),
                   label: "易拍区",
                 ),
                 BottomNavigationBarItem(
                   icon:logic.currentIndex!=2?
                   Image.asset("assets/images/icon_tab_cart.png",gaplessPlayback: true)
                       :Image.asset("assets/images/icon_tab_cart_select.png",gaplessPlayback: true),
                   label: "购物车",
                 ),
                 BottomNavigationBarItem(
                     icon:logic.currentIndex!=3?
                     Image.asset("assets/images/icon_tab_me.png",gaplessPlayback: true,)
                         :Image.asset("assets/images/icon_tab_me_select.png",gaplessPlayback: true),
                     label: "我的"
                 )
               ],
             ),
           ),
         );
       },
     );
  }
}
